class Node():
    def __init__(self, data=None, next=None):
        self._data = data
        self._next = next
    def setData(self, NewData):
        self._data = NewData
    def setNext(self, NewNext):
        self._next = NewNext
    def getData(self):
        return self._data
    def getNext(self):
        return self._next
    
class LinkedList():
    def __init__(self):
        self._head = Node()
        self._length = 0
    def tail_add(self, NewData):
        NewNode = Node(NewData, None)
        if self._length == 0:
            self._head = NewNode
            self._length = 1
        else:
            current = self._head
            while current.getNext() != None:
                current = current.getNext()
            current.setNext(NewNode)
            self._length+=1
    def PrintLinkedList(self):
        curr = self._head
        while curr != None:
            print('打印节点:%s'%(curr.getData()))
            curr = curr.getNext()
    def getLength(self):
        return self._length
    
foods = ['apple', 'water', 'juice', 'tomato']
newLinked = LinkedList()
for s in foods:
    newLinked.tail_add(s)
print(newLinked.getLength())
newLinked.PrintLinkedList()